<?php 
	session_start();
	include '../../db.php';
	//echo $_REQUEST['searchval'];	 
	if(isset($_REQUEST['searchval'])){
		$salesm = $_REQUEST['searchval'];	
		$salesm_query = ($salesm == 'all')?"SELECT * FROM receipts":sprintf("SELECT * FROM receipts WHERE custName='%s'", mysql_real_escape_string($salesm));
		//$sql = sprintf("SELECT * FROM users WHERE user='%s');
		$html = '<table id="salesman-filter-table" name="salesman-filter-table" class="table table-striped table-hover">
								<thead>
									<tr>	
										<td>Salesman</td>
										<td>Proforma ID</td>	
										<td>Customer Name</td>	
										<td>Job Title</td>
										<td>P.O Box</td>
										<td>Address</td>
										<td>Mobile Number</td>									
										<td>Items</td>														
									</tr>
								</thead><tbody>';
		//echo $salesm_query;
		if ($result=mysql_query($salesm_query)) {// check if query has contents
			while ($row=mysql_fetch_array($result)) {// start fetching arrays 	<br>
				$html .= '<tr>
							<td>'.$row['salesman'].'</td>
							<td>'.$row['proformaID'].'</td>	
							<td>'.$row['custName'].'</td>	
							<td>'.$row['custJobTitle'].'</td>
							<td>'.$row['custPO'].'</td>
							<td>'.$row['custLocation'].'</td>
							<td>'.$row['custNumb'].'</td>												
							<td><a data-toggle="modal" href="inc/invoice/showitems.inc.php?sid='.$row['proformaID'].'" data-target="#modal_filter">show items</a></td>														
						</tr>';
			}
		}
		$html .= '</tbody></table>';
		echo $html;
	}else{
		echo 'no data received';
	}
	 
?>